<template>
  <div class="dashboard-editor-container">
    <div class=" clearfix">
      <pan-thumb image="https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png" style="float: left">
        Your roles:
        <span style="font-size: 25px" v-for="item in roles" :key="item" class="pan-info-roles">{{ item }}</span>
      </pan-thumb>
      <github-corner style="position: absolute; top: 0px; border: 0; right: 0;"/>
      <div class="info-container">
        <span class="display_name">{{ name }}</span>
        <span v-if="!admin">
        <span style="font-size:20px;padding-top:20px;display:inline-block;" v-if="isTrue">今天轮到你值班,不能浪了</span>
        <span style="font-size:20px;padding-top:20px;display:inline-block;" v-else>今天不是你值班,尽情的浪</span>
          </span>
        <span v-else>boss需要值班?</span>
      </div>
    </div>
    <div>
      <img :src="emptyGif" class="emptyGif">
    </div>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
import PanThumb from '@/components/PanThumb'
import GithubCorner from '@/components/GithubCorner'
import {getSchedule} from "@/api/schedule";

export default {
  name: 'DashboardEditor',
  components: {PanThumb, GithubCorner},
  data() {
    return {
      isTrue: false,
      admin: false,
      emptyGif: 'https://wpimg.wallstcn.com/0e03b7da-db9e-4819-ba10-9016ddfdaed3'
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'roles'
    ])
  },
  created() {
    if (this.roles.includes('admin')) {
      this.admin = true
      return;
    }
    getSchedule().then(res => {
      this.isTrue = res.content
    })
  }
}
</script>

<style lang="scss" scoped>
.emptyGif {
  display: block;
  width: 45%;
  margin: 0 auto;
}

.dashboard-editor-container {
  background-color: #e3e3e3;
  min-height: 100vh;
  padding: 50px 60px 0px;

  .pan-info-roles {
    font-size: 12px;
    font-weight: 700;
    color: #333;
    display: block;
  }

  .info-container {
    position: relative;
    margin-left: 190px;
    height: 150px;
    line-height: 200px;

    .display_name {
      font-size: 48px;
      line-height: 48px;
      color: #212121;
      position: absolute;
      top: 25px;
    }
  }
}
</style>
